﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Silverlight.Testing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PlottingBasics.LINQHelpers;
using System.Linq;

namespace t_PlottingBasics
{
    [TestClass]
    public class t_Difference
    {
        [TestMethod]
        public void TestNullSequenceLast()
        {
            double[] ar = new double[0];
            var r = ar.DeltaLast(v => v);
            Assert.AreEqual(0, r.Count(), "The number of guys that came back is zero");
        }

        [TestMethod]
        public void TestOneSequenceLast()
        {
            double[] ar = new double[] { 5.0 };
            var r = ar.DeltaLast(v => v);
            Assert.AreEqual(1, r.Count(), "The number of guys that came back is zero");
            Assert.AreEqual(0.0, r.First(), "The delta of a single element should be 0");
        }

        [TestMethod]
        public void TestTwoSequenceLast()
        {
            double[] ar = new double[] { 5.0, 10.0 };
            var r = ar.DeltaLast(v => v);
            Assert.AreEqual(2, r.Count(), "The number of guys that came back is zero");
            Assert.AreEqual(0.0, r.First(), "The delta of a single element should be 0");
            Assert.AreEqual(5.0, r.Last(), "The delta should have been correct");
        }
        [TestMethod]
        public void TestNullSequenceFirst()
        {
            double[] ar = new double[0];
            var r = ar.DeltaFirst(v => v);
            Assert.AreEqual(0, r.Count(), "The number of guys that came back is zero");
        }

        [TestMethod]
        public void TestOneSequenceFirst()
        {
            double[] ar = new double[] { 5.0 };
            var r = ar.DeltaFirst(v => v);
            Assert.AreEqual(1, r.Count(), "The number of guys that came back is zero");
            Assert.AreEqual(0.0, r.First(), "The delta of a single element should be 0");
        }

        [TestMethod]
        public void TestTwoSequenceFirst()
        {
            double[] ar = new double[] { 5.0, 10.0 };
            var r = ar.DeltaFirst(v => v);
            Assert.AreEqual(2, r.Count(), "The number of guys that came back is zero");
            Assert.AreEqual(5.0, r.First(), "The delta of a single element should be 0");
            Assert.AreEqual(0.0, r.Last(), "The delta should have been correct");
        }
        [TestMethod]
        public void TestNullSequence()
        {
            double[] ar = new double[0];
            var r = ar.Delta(v => v);
            Assert.AreEqual(0, r.Count(), "The number of guys that came back is zero");
        }

        [TestMethod]
        public void TestOneSequence()
        {
            double[] ar = new double[] { 5.0 };
            var r = ar.Delta(v => v);
            Assert.AreEqual(0, r.Count(), "The number of guys that came back is zero");
        }

        [TestMethod]
        public void TestTwoSequence()
        {
            double[] ar = new double[] { 5.0, 10.0 };
            var r = ar.Delta(v => v);
            Assert.AreEqual(1, r.Count(), "The number of guys that came back is zero");
            Assert.AreEqual(5.0, r.First(), "The delta of a single element should be 0");
        }
    }
}